﻿CREATE PROCEDURE [dbo].[smenu_TrackerRequest_SendApprovalEMail]
(	@TrackerRequestID int,
	@RequestType varchar(128)
)
AS
SET NOCOUNT ON

DECLARE @To nvarchar(4000) SET @To = dbo.Config_TrackerRequestApprovalEMail()
DECLARE @DealerName sysname,@VIN varchar(17)
	SELECT @VIN = t_TrackerRequest.VIN, @DealerName = t_Dealer.Name FROM t_TrackerRequest INNER JOIN t_Dealer ON t_TrackerRequest.DealerID = t_Dealer.ID WHERE t_TrackerRequest.ID = @TrackerRequestID
DECLARE @Body nvarchar(4000)SET @Body = '<A href='''+dbo.Config_ShowTrackerRequest(@TrackerRequestID)+'''>Tracker Request</A>'
DECLARE @Subject nvarchar(512) SET @Subject = 'Request for tracker '+@RequestType
PRINT @To
EXEC msdb.dbo.sp_send_dbmail @recipients=@To,@subject=@Subject,@body=@Body,@body_format='HTML',@importance='High'

